<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>留学生管理系统</title>
        <link rel="stylesheet" href="${path}/css/admin2.css">
        <script>
            var _current_item = "#adminScoreManage";
        </script>
        <script type="text/javascript" src="${path}/js/jquery.min.js"></script>
        <style>
        #set_pannalF,#set_pannalH{
                margin: 15% auto;
                padding: 10px;
                width: 400px;
            }
            #set_pannalH td{
            text-align:left;
            padding-left:20px;
            }
            #set_pannalH input{
            width:100px;
            }
        </style>
        <script>
 
            function setSelectChecked(selectId, checkValue){  
            	
                var select = document.getElementById(selectId);  
                for(var i=0; i<select.options.length; i++){  
                    if(select.options[i].value == checkValue){  
                        select.options[i].selected = true;
                        break;  
                    }  
                }  
            };
            
           
        </script>
    </head>
    <body>
    <div id="above-mask">
            <!--  pannal -->
           	<div class="pannel hide"  id="set_pannalH">
           		<div class="close-container">
                    <a class="close" onclick="hide('#mask,#above-mask,#set_pannalH')">&times;</a>
                </div>
                <div>成绩修改：</div><br />
                <table>
                <tr><td>平时成绩：</td><td><input id="dailyH"></td></tr>
                <tr><td>实验成绩：</td><td><input id="expH"></td></tr>
                <tr><td>其他成绩：</td><td><input id="otherH"></td></tr>
                <tr><td>期末成绩：</td><td><input id="finalH">&nbsp;&nbsp;<select id="selH"><option value="正常">正常</option><option value="旷考">旷考</option><option value="作弊">作弊</option></select></td></tr>
                </table>
				<button style="margin-left:0;width:100%" id="add_confH" onclick="editH(this);">确定</button>
           	</div>
           <!--  pannal end-->
           <!--  pannal -->
           	<div class="pannel hide"  id="set_pannalF">
           		<div class="close-container">
                    <a class="close" onclick="hide('#mask,#above-mask,#set_pannalF')">&times;</a>
                </div>
                <div>成绩修改：</div><br />
                <table>
                <tr><td style="width:150px">平时成绩：</td><td><select id="selD"><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="P">P</option><option value="F">F</option></select></td></tr>
                <tr><td>实验成绩：</td><td><select id="selE"><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="P">P</option><option value="F">F</option></select></td></tr>
                <tr><td>其他成绩：</td><td><select id="selO"><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="P">P</option><option value="F">F</option></select></td></tr>
                <tr><td>期末成绩：</td><td><select id="selF"><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="P">P</option><option value="F">F</option><option value="旷考">旷考</option><option value="作弊">作弊</option></select></td></tr>
                </table>
				<button style="margin-left:0;width:100%" id="add_confF" onclick="editF(this);">确定</button>
           	</div>
           <!--  pannal end-->
           </div>
        <div id="mask"></div>
        <div id="header"></div>
        <div id="main">
            <div id="side-menu"></div>
            <div id="container">
                <div id="inner-border">
                    <div class="manage">
                        <div class="c1">
                            <span class="c5"><#if courseName??>${courseName}</#if></span>                        
                            <#if uuid??>
                            <#if nodat??>
                                <button type="button" class="form-group btn btn-primary btn-sm se1">导出Excel</button>                              
                            <#else>
                                <button type="button" class="form-group btn btn-primary btn-sm se1" onclick="window.location.href = '${path}/scoreExport/exportExcel?uuid=${uuid}'">导出Excel</button>
                            </#if>
                            </#if>
                        </div>
                        <br>
                        <div class="table3">
                            <table class="table table-bordered" id="couscotable">
                                <thead>
                                    <tr>
                                        <th>护照号</th> 
                                        <th>学号</th> 

                                        <th>姓</th>
                                        <th>名</th>
                                        <th>专业</th> 
                                        <!-- <th>入学年份</th> 
                                        <th>入学季度</th> -->
                                        <th>平时成绩</th>
                                        <th>实验成绩</th> 
                                        <th>其他成绩</th> 
                                        <th>期末成绩</th>
                                        <th>成绩</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <#if allStuGra??>
                                    <#list allStuGra as rs>
                                    <tr>
                                        <td>${rs.newpassportNo!}</td>
                                         <td>${rs.sNo!}</td>
                                        <td>${rs.lastName!}</td>
                                        <td>${rs.firstName!}</td>
                                        <td>${rs.majorName!}</td>
                                       <!--  <td>${rs.eduStartDate!}</td>
                                        <td>${rs.eduSeason!}</td> -->
                                        <td>${rs.dailyGrade!}</td>
                                        <td>${rs.experimentalGrade!}</td>
                                        <td>${rs.otherGrade!}</td>
                                        <td>${rs.finalGrade!}</td>
                                        
                                        <td>${rs.grade!}</td>
                                        <td><button class="edit" passportNo="${rs.passportNo!}" onclick="setOne(this);">修改</button></td>
                                    </tr>
                                    </#list>
                                    </#if>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                
            </div>
        </div>
        <div id="footer"></div>
        <script type="text/javascript" src="${path}/js/admin-main-appearance.js"></script>

        <!-- DataTables JavaScript -->
        <script src="${path}/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetHiddenNodes.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTd.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTds.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetColumnData.js"></script>
        <script src="${path}/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
        <script type="text/javascript">
                                $(document).ready(function () {
                                    $('#couscotable').DataTable({
                                        responsive: true,
                                        ordering: false,
                                        searching: true,
                                        "bLengthChange": false,
                                        "bRetrieve": true,
                                        "bFilter": true//过滤功能

                                    });
                                });
                                
                                function setOne(obj){
                                //alert("${gradeType!}");
                                if("${gradeType!}"=="H"){
                                var tr = obj.parentNode.parentNode;
                                var passportNo=obj.getAttribute("passportNo");
                                var dailyGrade =tr.cells[5].innerHTML;
                                var experimentalGrade =tr.cells[6].innerHTML;
                                var otherGrade =tr.cells[7].innerHTML;
                                var finalGrade =tr.cells[8].innerHTML;
                                //alert();
                                $("#add_confH").attr("passportNo",passportNo);
                                $("#dailyH").val(dailyGrade);
                                $("#expH").val(experimentalGrade);
                                $("#otherH").val(otherGrade);
                                $("#finalH").val(finalGrade);
                                if(finalGrade=="旷考"){
                                	$("#selH").val("旷考");
                                }else if(finalGrade=="作弊"){
                                $("#selH").val("作弊");
                                }else{
                                $("#selH").val("正常");
                                }
                                
                              	show('#mask,#above-mask,#set_pannalH');
                              	}else{
                              	var tr = obj.parentNode.parentNode;
                              	var passportNo=obj.getAttribute("passportNo");
                                var dailyGrade =tr.cells[5].innerHTML;
                                var experimentalGrade =tr.cells[6].innerHTML;
                                var otherGrade =tr.cells[7].innerHTML;
                                var finalGrade =tr.cells[8].innerHTML;
                                //alert();
                               $("#add_confF").attr("passportNo",passportNo);
                               setSelectChecked("selD",dailyGrade);
                               setSelectChecked("selE",experimentalGrade);
                               setSelectChecked("selO",otherGrade);
                               setSelectChecked("selF",finalGrade);
                              	show('#mask,#above-mask,#set_pannalF');
                              	
                              	}
                                }
                           function editH(obj){
                           		var testNo="${testNo!}";
                           		var passportNo = obj.getAttribute("passportNo");
                           		var selH = $("#selH").val();
                           		var dailyGrade =$("#dailyH").val();
                                var experimentalGrade =$("#expH").val();
                                var otherGrade =$("#otherH").val();
                                if(selH=="旷考"){
                                var finalGrade = "旷考";
                                }else if(selH=="作弊"){
                                var finalGrade = "作弊";
                                }else{
                                var finalGrade =$("#finalH").val();
                                }
                                //alert(selH);
                                //alert(finalGrade);
                                
                                 $.ajax({
                                    type: "post",
                                    url: '${path}/scoreMana/updateStudentGrade',
                                    data: {
                                    dailyGrade:dailyGrade,
                                    experimentalGrade:experimentalGrade,
                                    otherGrade:otherGrade,
                                    finalGrade:finalGrade,
                                    testNo:testNo,
                                    passportNo:passportNo,
                                    },
                                    datatype: "json",
                                    success: function (data) {
                                    hide('#mask,#above-mask,#set_pannalH');
                                    },
                                    error:function (err){
                                    }
                                    });
                           
                           }
                           
                           function editF(obj){
                           		var testNo="${testNo!}";
                           		var dailyGrade =$("#selD").val();
                                var experimentalGrade =$("#selE").val();
                                var otherGrade =$("#selO").val();
                                var finalGrade =$("#selF").val();
                                var passportNo = obj.getAttribute("passportNo");
                                //alert(finalGrade);
                                $.ajax({
                                    type: "post",
                                    url: '${path}/scoreMana/updateStudentGrade',
                                    data: {
                                    dailyGrade:dailyGrade,
                                    experimentalGrade:experimentalGrade,
                                    otherGrade:otherGrade,
                                    finalGrade:finalGrade,
                                    testNo:testNo,
                                    passportNo:passportNo,
                                    },
                                    datatype: "json",
                                    success: function (data) {
                                    hide('#mask,#above-mask,#set_pannalF');
                                    location.reload();
                                    },
                                    error:function (err){
                                    }
                                    });
                           
                           }
        </script>
    </body>
</html>
